global class TstBatchApex implements Database.Batchable<sObject>{
   global final String Query;
   global final String Entity;
   global final String Field;
   global final String Value;

   global TstBatchApex (String q){
   this.Query = q;
   }

   global Database.QueryLocator start(Database.BatchableContext BC){
       for(Integer i=0; i<10000; i++){
       }
      return Database.getQueryLocator(query);
   }

   global void execute(Database.BatchableContext BC, 
                       List<SObject> scope){
      for(Integer i=0; i<10000; i++){
      }
      List<Batch__c> bList = new List<Batch__c>();
      List<Batch__c> newIns = new List<Batch__c>();
      Batch__c b;
      for(SObject s : scope){
          b = (Batch__c)s; 
          b.Name= BatchApexController.BatchName ; 
          bList.add(b);
      }      
      update bList;
      
      Batch__c b1 = new Batch__c(Name ='INS1');
      newIns.add(b1);
      Batch__c b2 = new Batch__c(Name ='INS2');
      newIns.add(b2);
      insert newIns;
      System.debug('***********In FINISH'+BatchApexController.flag);
   }

   global void finish(Database.BatchableContext BC){
        BatchApexController.flag= true;
        System.debug('***********In FINISH'+BatchApexController.flag);
        
   }

}